function val = fun_to_minimize_to_fit_lognormal(kappac,kappa_star,probgiving,psivector)
    
    pd = makedist('LogNormal','mu',psivector(1),'sigma',psivector(2));

    cdfdiff = (1 - cdf('LogNormal',kappa_star,psivector(1),psivector(2))) - probgiving;
    relmeandiff = (mean(pd) - kappac)/kappac;
    val =  cdfdiff^2 + relmeandiff^2;

 